package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: 市场活动详情页 活动成效-tab 指标
 *
 * @author chunyang.qin
 * @version v1.0
 * @date 2019/2/18 19:27
 * @since v1.0
 */
@Getter
public enum MarketActivityEffectTargetEnum {
    //线索数量
    ALL_CLUE_COUNT(1,"allClueCount","enum.marketActivityEffectTarget.name.all_clue_count","enum.marketActivityEffectTarget.unit.all_clue_count"),
    //有效线索数量
    EFFECTIVE_CLUE_COUNT(2,"effectiveClueCount","enum.marketActivityEffectTarget.name.effective_clue_count","enum.marketActivityEffectTarget.unit.effective_clue_count"),
    //转化线索数量
    TRANSFORMED_CLUE_COUNT(3,"transformedClueCount","enum.marketActivityEffectTarget.name.transformed_clue_count","enum.marketActivityEffectTarget.unit.transformed_clue_count"),
    //客户数量
    CUSTOMER_COUNT(4,"customerCount","enum.marketActivityEffectTarget.name.customer_count","enum.marketActivityEffectTarget.unit.customer_count"),
    //线索转客户转化率
    CLUE_CUSTOMER_RATE(5,"clueCustomerRate","enum.marketActivityEffectTarget.name.clue_customer_rate","enum.marketActivityEffectTarget.unit.clue_customer_rate"),
    //机会数量
    ALL_OPPORTUNITY_COUNT(6,"allOpportunityCount","enum.marketActivityEffectTarget.name.all_opportunity_count","enum.marketActivityEffectTarget.unit.all_opportunity_count"),
    //机会金额
    ALL_OPPORTUNITY_AMOUNT (7,"allOpportunityAmount","enum.marketActivityEffectTarget.name.all_opportunity_amount","enum.marketActivityEffectTarget.unit.all_opportunity_amount"),
    //线索转机会转化率
    CLUE_OPPORTUNITY_RATE(8,"clueOpportunityRate","enum.marketActivityEffectTarget.name.clue_opportunity_rate","enum.marketActivityEffectTarget.unit.clue_opportunity_rate"),
    //赢单机会数量
    WIN_OPPORTUNITY_COUNT(9,"winOpportunityCount","enum.marketActivityEffectTarget.name.win_opportunity_count","enum.marketActivityEffectTarget.unit.win_opportunity_count"),
    //赢单机会金额
    WIN_OPPORTUNITY_AMOUNT(10,"winOpportunityAmount","enum.marketActivityEffectTarget.name.win_opportunity_amount","enum.marketActivityEffectTarget.unit.win_opportunity_amount"),
    //合同订单数
    ALL_CONTRACT_COUNT(11,"allContractCount","enum.marketActivityEffectTarget.name.all_contract_count","enum.marketActivityEffectTarget.unit.all_contract_count"),
    //合同订单金额
    ALL_CONTRACT_AMOUNT(12,"allContractAmount","enum.marketActivityEffectTarget.name.all_contract_amount","enum.marketActivityEffectTarget.unit.all_contract_amount"),
    //线索转合同转化率
    CLUE_CONTRACT_RATE(13,"clueContractRate","enum.marketActivityEffectTarget.name.clue_contract_rate","enum.marketActivityEffectTarget.unit.clue_contract_rate");


    /**
     * 枚举值 --
     */
    private final int code;

    /**
     * 枚举信息--英文名称 -- 与targetLogEntity内指标属性名一致
     */
    private final String alias;

    /**
     * 枚举信息--中文名称
     */
    private final String name;

    /**
     * 枚举值类型--单位：元、个
     */
    private final String unit;


    /**
     * 构造一个<code>TargetEnum</code>枚举对象
     *
     * @param code
     * @param name
     */
    MarketActivityEffectTargetEnum(int code, String alias, String name, String unit) {
        this.code = code;
        this.alias = alias;
        this.name = name;
        this.unit = unit;
    }

    /**
     * 通过枚举<code>code</code>获得枚举
     *
     * @return TargetEnum
     */
    public static MarketActivityEffectTargetEnum getByCode(Integer code) {
        for (MarketActivityEffectTargetEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return null;
    }

    /**
     * 根据指标code获取指标名称
     *
     * @param code
     * @return
     * @version
     * @author cp.zhang
     * 创建时间：2017-8-2 下午5:19:26
     * 修改时间：
     * @since
     */
    public static String getNameByCode(Integer code) {
        String name = "";
        for (MarketActivityEffectTargetEnum cache : values()) {
            if (code.equals(cache.getCode())) {
                name = cache.getName();
            }
        }
        return name;
    }

    /**
     * 获取全部枚举
     *
     * @return List<TargetEnum>
     */
    public static List<MarketActivityEffectTargetEnum> getAllEnum() {
        List<MarketActivityEffectTargetEnum> list = new ArrayList<>();
        for (MarketActivityEffectTargetEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }

    /**
     * 获取全部枚举code
     *
     * @return
     */
    public static List<Integer> getAllEnumCode() {
        List<Integer> list = new ArrayList<>();
        for (MarketActivityEffectTargetEnum cache : values()) {
            list.add(cache.getCode());
        }
        return list;
    }


    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public String getUnit() {
        return I18nMessageUtil.getMessage(unit);
    }
}
